package com.example.computer_exam_training_sys.service.impl;

import com.example.computer_exam_training_sys.mapper.FeedbackVOMapper;
import com.example.computer_exam_training_sys.service.FeedbackVOService;
import com.example.computer_exam_training_sys.vo.FeedbackDetailVO;
import com.example.computer_exam_training_sys.vo.FeedbackListVO;
import com.example.computer_exam_training_sys.vo.FeedbackResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedbackVOServiceImpl implements FeedbackVOService {
    @Autowired
    private FeedbackVOMapper feedbackVOMapper;

    @Override
    public List<FeedbackListVO> getFeedbackList() {
        return feedbackVOMapper.selectFeedbackList();
    }

    @Override
    public FeedbackDetailVO getFeedbackDetail(Integer feedbackId) {
        FeedbackDetailVO detail = feedbackVOMapper.selectFeedbackDetail(feedbackId);
        if (detail != null) {
            List<FeedbackResponseVO> responses = feedbackVOMapper.selectFeedbackResponses(feedbackId);
            detail.setResponses(responses);
        }
        return detail;
    }

    @Override
    public List<FeedbackListVO> getFeedbackListByUserId(Integer userId) {
        return feedbackVOMapper.selectFeedbackListByUserId(userId);
    }
}
